﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Talentnet.Core.Web;

[PageTextResource("LoginUserInfo")]
public partial class global_LoginUserInfo : NormalUserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {

        if (SessionManager.CurrentUser != null)
        {
            if (Page.CurrentLanguage == "vn")
            {
                ctrlUserName.Text = SessionManager.CurrentUser.UserNameLast + " " + SessionManager.CurrentUser.UserNameFirst;
            }
            else
            {
                ctrlUserName.Text = SessionManager.CurrentUser.UserNameFirst + " " + SessionManager.CurrentUser.UserNameLast;
            }
            ctrlUserInfoPanel.Visible = true;
            ctrlNotLogIn.Visible = false;
        }
        else
        {
            if (HttpContext.Current.User.Identity.IsAuthenticated && Request.RawUrl.ToLower().IndexOf("login.aspx") == -1)
            {
                HttpContext.Current.Response.Redirect(FormsAuthentication.LoginUrl);
            }
            else
            {
                ctrlUserInfoPanel.Visible = false;
                ctrlNotLogIn.Visible = true;
            }
        }
    }

    protected void ctrlLogoff_Click(object sender, EventArgs e)
    {
        FormsAuthentication.SignOut();
        Session.Clear();
        Session.Abandon();
        Response.Redirect(FormsAuthentication.LoginUrl);
    }
}
